package com.yidu.ruifeng_logistics.service.impl;

import com.yidu.ruifeng_logistics.entity.LogisticsArea;
import com.yidu.ruifeng_logistics.dao.LogisticsAreaDao;
import com.yidu.ruifeng_logistics.service.LogisticsAreaService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 地区表(LogisticsArea)表服务实现类
 *
 * @author makejava
 * @since 2021-03-09 14:24:36
 */
@Service("logisticsAreaService")
public class LogisticsAreaServiceImpl implements LogisticsAreaService {
    @Resource
    private LogisticsAreaDao logisticsAreaDao;

    /**
     * 通过ID查询单条数据
     *
     * @param areaId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsArea queryById(Integer areaId) {
        return this.logisticsAreaDao.queryById(areaId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsArea> queryAllByLimit(int offset, int limit) {
        return this.logisticsAreaDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsArea 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsArea insert(LogisticsArea logisticsArea) {
        this.logisticsAreaDao.insert(logisticsArea);
        return logisticsArea;
    }

    /**
     * 修改数据
     *
     * @param logisticsArea 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsArea update(LogisticsArea logisticsArea) {
        this.logisticsAreaDao.update(logisticsArea);
        return this.queryById(logisticsArea.getAreaId());
    }

    /**
     * 通过主键删除数据
     *
     * @param areaId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer areaId) {
        return this.logisticsAreaDao.deleteById(areaId) > 0;
    }

    @Override
    public List<LogisticsArea> queryAll(LogisticsArea logisticsArea) {
        return this.logisticsAreaDao.queryAll(logisticsArea);
    }


    /**
     * 查询一级
     * @param yi
     * @return
     */
    @Override
    public List<LogisticsArea> selectYi(Integer yi) {
        return logisticsAreaDao.selectYi(yi);
    }

    /**
     * 查询二级
     * @param er
     * @return
     */
    @Override
    public List<LogisticsArea> selectEr(Integer er) {
        return logisticsAreaDao.selectEr(er);
    }

    @Override
    public List<LogisticsArea> createOption() {
        return logisticsAreaDao.createOption();
    }

}
